#include "OtherRT.h"



void OtherRT::deleteProduct(vector<Product> &prods) {
    int tempProductId;
	
	cout << "Product ID: ";		
    cin >> tempProductId;
    
    Product prd;			// temporary product found
    bool isExist = false;
    for (int i = 0; i < prods.size(); ++i) {
		// input product_id valid
        if (prods[i].get_prod_id() == tempProductId) {
            //prods[i].set_cat_id(999);					// Cat ID= 999; Mean:Delete relation between product and category (Delete Product From category)
            cout << "success";
			isExist = true;
            break;
        }
    }
	// input product id not valid
    if (!isExist) {
        cout << "Product id " << tempProductId << " not found." << endl;
        return;
    }
}

void OtherRT::changePrice(vector<Product> &prods) {
    int tempProductId;
	int newPrice;
	
	cout << "Product ID: ";				// Insert Product Id
    cin >> tempProductId;
    
	
    Product prd;			// temporary product found
    bool isExist = false;
    for (int i = 0; i < prods.size(); ++i) {
		// input product_id valid
        if (prods[i].get_prod_id() == tempProductId) {
            
			
			cout << "Insert new price: ";
			cin >> 	newPrice;
			//change Price
			
			cout << "Product price changed."
			isExist = true;
            break;
        }
    }
	// input product id not valid
    if (!isExist) {
        cout << "Product id " << tempProductId << " not found." << endl;
        return;
    }
}

void OtherRT::addNewCategory(vector<Category> &cats) {
    int newCategoryID;
	int newCategoryName;
	
	cout << "Insert Category ID : ";				// Insert category Id
    cin >> newCategoryID;
	
	cout << "Insert Category Name : ";				// Insert category name
    cin >> newCategoryID;
    
	cats.push_back(Category(newCategoryID, newCategoryName));

}
